---@class UICityMiniChatPanel : UIComponentBase
local UICityMiniChatPanel = Class("UICityMiniChatPanel",UIComponentBase)
local t = UICityMiniChatPanel
function t:ctor(obj)
    self.fguiObj = obj
    self:OnCreate()
end

function t:OnCreate()
    self.chatItem = self:GetChild("chat")
    self.chatItem.touchable = false
    self.name = self:GetChild("otherName",self.chatItem)
    self.content = self:GetChild("otherDialog",self.chatItem)
    self.bg = self:GetChild("framebg")
    self.ctrlType = self:GetController("type")
    logicMgr.ChatManager.LoadEmoji()
    logicMgr.ChatManager.LoadAllMsgFromFile()
    self:RegisterOnClick(self.bg,self.ClickItem)

    ListenEvent(Config.EventType.Fresh_Chat,self.Fresh_ChatMsg,self)
end
function t:Refresh()
   -- local item = CtrlManager.GetCtrl(PanelNames.ChatMsgItem);
    local data
    if logicMgr.LBSManager.isSelectLBS then
        data = logicMgr.ChatManager.GetLastChatMsg(Config.MsgChannel.LBS)
    else
        data = logicMgr.ChatManager.GetLastChatMsg(Config.MsgChannel.Server)
    end
    if data == nil then
        self.name.text = ""
        self.content.text = ""
        self.fguiObj.visible = false
    else
        self.name.text = data.roleName.."："
        local m = logicMgr.ChatManager.TransferEmojiName(data.Message)
        if string.lenUtf8(m) > 8 then
            m = string.limitstr(m,7)..".."
        end
        self.content.text = m
        self.fguiObj.visible = true
        --item.initData(self.chatItem,data,true);
    end
end
function t:OnEnable()

end
function t:OnDisable()
end
function t:OnDestroy()
    self.fguiObj = nil
    CloseEvent(Config.EventType.Fresh_Chat,self.Fresh_ChatMsg,self)
end
function t:Fresh_ChatMsg(msg)
    self:Refresh(msg)
end
function t:ClickItem()
    showUI(PanelNames.UIChatPanel);
end
return t